//
//  SystemSettingsViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/15.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "SystemSettingsViewController.h"
#import "RDVTabBarController.h"
#import "AboutUsViewController.h"

#import "TheLoginViewController.h"
#import "InformationFeedbackViewController.h"
#import "AccountManagementViewController.h"
@interface SystemSettingsViewController ()<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate, UITextViewDelegate,UIImagePickerControllerDelegate,UIAlertViewDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIActionSheetDelegate>
{
    
    NSArray *array;
    NSArray *array1;
    NSArray *array2;
    NSArray *array3;
    UIButton *noticeCountBtn;
    UIWebView *web;
    UIButton* name1;
    UIButton* name;
//    ReabamSingleton* commdity;
    UIButton *imageView ;
    UIView *footerView;
    UIButton* renzhenButton;
}

@end

@implementation SystemSettingsViewController
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    self.navigationController.delegate = nil;
    
}
-(void)BackAction:(UIButton *)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden = NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
       
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self loadViewTabel];
//    commdity=[ReabamSingleton shared];
    [self tableHeadView];
    
    self.title = @"系统设置";
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];

    
}

- (void)loadViewTabel{
    
   
    array = @[@"清除缓存",@"意见反馈"];
    
}

//表头视图
- (void)tableHeadView
{
    footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth,200)];
    UIButton*outBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 80, ScreenWidth-20, anniuHeigth)];
    [outBtn setTitle:@"退出登录" forState:UIControlStateNormal];
    [outBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    outBtn.backgroundColor=[UIColor whiteColor];
    [outBtn.layer setCornerRadius:3.0]; //设置矩圆角半径
    [outBtn.layer setBorderWidth:0.5];   //边框宽度
    CGColorSpaceRef registedSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef tureBTncolorref1 = CGColorCreate(registedSpace,(CGFloat[]){ 224/255.0, 224/255.0, 224/255.0, 1.0 });
    [outBtn.layer setBorderColor:tureBTncolorref1];//边框颜色

    [outBtn addTarget:self action:@selector(outBtn:) forControlEvents:UIControlEventTouchUpInside];
    [footerView addSubview:outBtn];
    
    
    _table.frame=CGRectMake(0, -20, ScreenWidth, ScreenHeight-64-49);
    [self.table reloadData];
    self.table.tableFooterView = footerView;
}
-(void)outBtn:(UIButton*)sender{

    UIAlertView* alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"是否确认注销？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
    [alt show];


}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex == 1) {
        
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        [user removeObjectForKey:@"tokenId"];
        
        [user synchronize];
//         commdity.shouye=@"shouye";
        // [APService setAlias:@"" callbackSelector:nil object:self];
        TheLoginViewController* Login=[[TheLoginViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];

        
    }
    
}



#pragma mark--TableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1 ;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  
    return array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    cell.textLabel.text = [array objectAtIndex:indexPath.row];
    cell.textLabel.font=[UIFont systemFontOfSize:16];
    if (array.count ==indexPath.row+1) {
        UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 55-0.35, ScreenWidth, 0.45)];
        lineLabel1.backgroundColor=qianhuiColor;
        [cell.contentView addSubview:lineLabel1];
        
    }
    
    return cell;
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return  55;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  
    
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UITableViewCell *cell =(UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
    
    if ([cell.textLabel.text isEqualToString:@"关于我们"]) {
        
        AboutUsViewController * Login=[[AboutUsViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];
        
    }else if ([cell.textLabel.text isEqualToString:@"意见反馈"]) {
        InformationFeedbackViewController*detailViewController = [[InformationFeedbackViewController alloc] init];
        
        [self.navigationController pushViewController:detailViewController animated:YES];
        
        
    }else if ([cell.textLabel.text isEqualToString:@"账户管理"]) {
        AccountManagementViewController*detailViewController = [[AccountManagementViewController alloc] init];
        
        [self.navigationController pushViewController:detailViewController animated:YES];
        
        
    }
    
    
    
    
    
}




-(void)requestData:(UIButton *)sender{
    
    TheLoginViewController* Login=[[TheLoginViewController alloc]init];
      
    [self.navigationController pushViewController:Login animated:YES];
    
    
    
}


@end
